@using BXJG.Utils.Application.Share.Dtos
@using Microsoft.AspNetCore.Components.Sections
@using System.Linq
@using ZLJ.Application.Share.StaffInfo
@using ZLJ.RCL.Components.Post

@attribute [Authorize(PermissionNames.BXJGBaseInfoStaffInfoGet)]
@inherits DetailUpdateBaseComponent<StaffInfoDto, long, StaffInfoEditDto>

<SectionContent SectionName=@($"{Master}-detail-update-title")>
    <Icon Type=@detailUpdateIcon Theme=@IconThemeType.Outline />
    @(detailUpdateText)@(FuncName)
</SectionContent>
<SectionContent SectionName=@($"{Master}-detail-update-body")>


    <Form @ref="frm" ValidateOnChange="true" Model="editDto" LabelColSpan="6" WrapperColSpan="18" OnFinish="OnFinish" Loading="IsBusy">
        <GridRow>
            <GridCol Span="8">
                <FormItem Label="姓名">
                    @if (IsShowUpdate)
                    {
                        <Input @bind-Value="context.Name" AllowClear="true" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.Name
                        </span>
                    }
                </FormItem>
            </GridCol>
            <GridCol Span="8">
                <FormItem Label="性别">
                    @if (IsShowUpdate)
                    {
                        <EnumRadioGroup @bind-Value="context.Gender" ButtonStyle="RadioButtonStyle.Outline" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.GenderText
                        </span>
                    }
                </FormItem>
            </GridCol>


            <GridCol Span="8">
                <FormItem Label="是否启用">

                    @if (IsShowUpdate)
                    {
                        <Checkbox @bind-Value="context.IsActive" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            <Checkbox @bind-Value="dto.IsActive" Disabled />
                        </span>
                    }
                </FormItem>
            </GridCol>

        </GridRow>
        <GridRow>
            <GridCol Span="8">
                    <FormItem Label="身份证号">
                        @if (IsShowUpdate)
                        {
                            <Input @bind-Value="context.IdNumber" AllowClear="true" />
                        }
                        else
                        {
                            <span class="frm-field-readonly">
                                dto.IdNumber
                            </span>
                        }
                    </FormItem>
            </GridCol>
            <GridCol Span="8">
                <FormItem Label="出生日期">
                    @if (IsShowUpdate)
                    {
                        <DatePicker @bind-Value="context.Birthday" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.Birthday?.ToString("d")
                        </span>
                    }
                </FormItem>
            </GridCol>
            <GridCol Span="8">
                <FormItem Label="邮箱地址">
                    @if (IsShowUpdate)
                    {
                        <Input @bind-Value="context.EmailAddress" AllowClear="true" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.EmailAddress
                        </span>
                    }
                </FormItem>
            </GridCol>

        </GridRow>
        <GridRow>
            <GridCol Span="8">
                <FormItem Label="手机号">
                    @if (IsShowUpdate)
                    {
                        <Input @bind-Value="context.PhoneNumber" AllowClear="true" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.PhoneNumber
                        </span>
                    }
                </FormItem>
            </GridCol>
            <GridCol Span="8">
                <FormItem Label="所属地区">
                    @if (IsShowUpdate)
                    {
                        <AdministrativeTreeSelect @bind-TreeIdNullable=context.AreaId IsKeyId AllowClear />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.AreaDisplayName
                        </span>
                    }
                </FormItem>
            </GridCol>
            <GridCol Span="8">
                @* <FormItem LabelColSpan="3" WrapperColSpan="21"> *@
                <FormItem Label="地址">
                    @if (IsShowUpdate)
                    {
                        <Input @bind-Value="context.CurrentAddress" AllowClear="true" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.CurrentAddress
                        </span>
                    }
                </FormItem>
            </GridCol>
        </GridRow>
        <GridRow>
            <GridCol Span="8">
                <FormItem Label="入职日期">
                    @if (IsShowUpdate)
                    {
                        <DatePicker @bind-Value="context.InDate" AllowClear="true" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.InDate?.ToString("d")
                        </span>
                    }
                </FormItem>
            </GridCol>
            <GridCol Span="8">
                <FormItem Label="离职日期">
                    @if (IsShowUpdate)
                    {
                        <DatePicker @bind-Value="context.OutDate" AllowClear="true" />
                    }
                    else
                    {
                        <span class="frm-field-readonly">
                            @dto.OutDate?.ToString("d")
                        </span>
                    }
                </FormItem>
            </GridCol>
        </GridRow>
        <GridRow>

        </GridRow>
        <GridRow>
            <GridCol Span="24">
                <FormItem LabelColSpan="2" WrapperColSpan="22">
                    <Checkbox @bind-Value="context.IsEnableAccount" Disabled="!IsShowUpdate" />
                </FormItem>
            </GridCol>
        </GridRow>
        @if (context.IsEnableAccount)
        {
            <GridRow>
                <GridCol Span="8">
                    <FormItem Label="登录名">
                        <span class="frm-field-readonly">
                            @dto.OutDate?.ToString("d")
                        </span>
                    </FormItem>
                </GridCol>


                <GridCol Span="8">
                    <FormItem Label="密码">
                        <Checkbox @bind-Value="context.ChangePassword" />
                        @if (IsShowUpdate&& context.ChangePassword)
                        {
                            <InputPassword @bind-Value="context.Password" AllowClear="true"  />
                        }
                        else
                        {
                            <span class="frm-field-readonly">*********</span>
                        }
                    </FormItem>
                </GridCol>
                <GridCol Span="8">
                    <FormItem>
                        <LabelTemplate>
                            <div class="frm-item-label-box">
                                <Tooltip>
                                    <TitleTemplate>多次登录失败后是否锁定？</TitleTemplate>
                                    <ChildContent>

                                        <Icon Style="" Type="@IconType.Outline.QuestionCircle" Width="1.1rem" Height="1.1rem" />

                                    </ChildContent>
                                </Tooltip>
                                登录锁定
                            </div>
                        </LabelTemplate>
                        <ChildContent>
                            <Checkbox @bind-Value="context.IsLockoutEnabled" />
                        </ChildContent>
                    </FormItem>
                </GridCol>
            </GridRow>
        }


        <GridRow>
            <GridCol Span="24">
                <FormItem Label="角色" LabelColSpan="2" WrapperColSpan="22">
                    <PostSelect @bind-Names="dto.RoleNames" />
                </FormItem>
            </GridCol>
        </GridRow>


        <GridRow>
            <GridCol Span="24">
                <FormItem LabelColSpan="2" WrapperColSpan="22">
                    <Input @bind-Value="context.Remark" AllowClear="true" />
                </FormItem>
            </GridCol>
        </GridRow>

    </Form>


</SectionContent>
<SectionContent SectionName=@($"{Master}-detail-update-btns")>
    @if (IsShowDelete)
    {
        <Popconfirm Title="确定删除此项吗?" OnConfirm="BtnDeleteClick">
            <Button Loading=isDeleting Danger="true" Disabled="IsBusy">删除</Button>
        </Popconfirm>
    }
    <ButtonGroup>
        @if (IsShowRefresh)
        {
            <Button OnClick="BtnRefreshClick" Loading="isRefreshing" Disabled="IsBusy">刷新</Button>
        }
        @if (IsShowBeginEdit)
        {
            <Button OnClick="BtnBeginEditClick" Loading="isFormIniting" Type="@ButtonType.Primary" Disabled="IsBusy">修改</Button>
        }
        else if (IsShowUpdate)
        {
            <Button OnClick="BtnResetClick" Loading="isReseting" Disabled="IsBusy" Icon="@IconType.Outline.Redo">重置</Button>
            <Button OnClick="BtnCancelEditClick" Disabled="IsBusy" Icon="@IconType.Outline.Rollback">放弃修改</Button>
            <Button OnClick="BtnUpdateClick" Type="@ButtonType.Primary" Loading="isUpdating" Disabled="IsBusy" Icon="@IconType.Outline.Save">保存</Button>
        }
    </ButtonGroup>
</SectionContent>